package com.xidian.zhiancloud.controller.warnset;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.service.warnset.WarnMangerService;

@RestController
@RequestMapping("/warnset")
public class WarnManagerController extends BaseController {
	
	@Autowired
	WarnMangerService warnmanagerService;
	
	/**
     *  - 获取报警等级列表  接口   warnset/getLeveList
     * @param 参数无
     * @param
     * @return id,.`level`,levelname,warnname,warncolor，jobids，jobname
     */
	@RequestMapping(value = "/getLeveList")
    public ResultDTO getLeveList()
    {
		List<Map<String,String>> rt = warnmanagerService.getLeveList();
		
		return ResultDTO.successOf(rt, GeneralResponseEnums.SUCCESS);
    }
	
	/**
     *  - 修改报警等级职位  接口   warnset/updateWarnLevel
     * @param 参数 id,
     * @param jobids 职位id串
     * @return 
     */
	@RequestMapping(value = "/updateWarnLevel")
	public ResultDTO updateWarnLevel(Integer id,String jobids)
	{
		 int rt = warnmanagerService.updateWarnLevel(id, jobids);
		 if(rt<0)
		 {
			 return ResultDTO.successOf(GeneralResponseEnums.UPDATE_FAILED);
		 }
		 return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  - 获取 预警阀值设置列表  接口   warnset/getWarnSetList
     * @param 
     * @param 
     * @return id,pid,`name`, subid,level1,level1value,level2,level2value
		,level3,level3value,level4,level4value
     */
	@RequestMapping(value = "/getWarnSetList")
	public ResultDTO getWarnSetList()
	{
		Integer companyid = this.getSessionUserCompanyId().intValue();
		List<Map<String,String>> rt = warnmanagerService.getWarnSetList(companyid);
		
		return ResultDTO.successOf(rt, GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  - 获取 增加列表 接口   warnset/getAddWarnSetList
     * @param 
     * @param 
     * @return id,pid,`name`, desc
     */
	@RequestMapping(value = "/getAddWarnSetList")
	public ResultDTO getAddWarnSetList()
	{
		Integer companyid = this.getSessionUserCompanyId().intValue();
		List<Map<String,String>> rt = warnmanagerService.getAddWarnSetList(companyid);
		
		return ResultDTO.successOf(rt, GeneralResponseEnums.SUCCESS);
	}
	
	
	
	/**
     *  - 修改 预警阀值设置  接口   warnset/updateWarnValue
     * @param 参数 id,
     * @param value1, value2, value3, value4
     * @return 
     */
	@RequestMapping(value = "/updateWarnValue")
	public ResultDTO updateWarnValue(Integer id,Integer value1,Integer value2,Integer value3,Integer value4)
	{
		int rt = warnmanagerService.updateWarnValue(id, value1, value2, value3, value4);
		if(rt<0)
		{
			 return ResultDTO.successOf(GeneralResponseEnums.UPDATE_FAILED);
		}
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  - 删除阈值设置记录  接口   warnset/deleteWarnSet
     * @param 参数 id,
     * @param 
     * @return 
     */
	@RequestMapping(value = "/deleteWarnSet")
	public ResultDTO deleteWarnSet(Integer id)
	{
		int rt = warnmanagerService.deleteWarnSet(id);
		if(rt<0)
		 {
			 return ResultDTO.successOf(GeneralResponseEnums.UPDATE_FAILED);
		 }
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}
	
	/**
     *  - 增加阈值设置记录  接口   warnset/addWarnSet
     * @param 参数 id,
     * @param 
     * @return 
     */
	@RequestMapping(value = "/addWarnSet")
	public ResultDTO addWarnSet(Integer id)
	{
		int rt = warnmanagerService.addWarnSet(id);
		if(rt<0)
		 {
			 return ResultDTO.successOf(GeneralResponseEnums.UPDATE_FAILED);
		 }
		return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
	}

}
